<template>
  <el-row class="row">
    <el-col>
      <el-tabs v-model="activeName">
        <el-tab-pane label="课题管理" name="1">
          <el-col :span="24">
            <el-col :span="2">
              <el-button type="primary" icon="el-icon-search" @click="topicSearch">搜索</el-button>
            </el-col>
            <el-col :span="5">
              <el-input
                placeholder="请输入课题"
                v-model="input"
                clearable>
              </el-input>
            </el-col>
            <el-col :span="2" :offset="14">
              <el-button type="primary" plain icon="el-icon-plus" @click="addTopicBtn">添加课题</el-button>
              <el-dialog
                v-loading="addTopicLoading"
                title="添加课题"
                :visible.sync="dialogVisible"
                width="30%"
                :before-close="handleClose">
                <el-form :model="form" status-icon :rules="rules" ref="form">
                  <el-form-item label="课题类型" prop="type" :label-width="formLabelWidth">
                    <el-input v-model="form.type"></el-input>
                  </el-form-item>
                  <el-form-item label="年级" prop="grade" :label-width="formLabelWidth">
                    <el-select v-model="form.grade" placeholder="请选择" style="width: 100%">
                      <el-option
                        v-for="item in gradeOptions"
                        :key="item"
                        :label="item+' 级'"
                        :value="item">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="指导教师" prop="teacher" :label-width="formLabelWidth">
                    <el-input v-model="form.teacher" disabled></el-input>
                  </el-form-item>
                  <el-form-item label="类型描述" prop="comment" :label-width="formLabelWidth">
                    <el-input v-model="form.comment"></el-input>
                  </el-form-item>
                </el-form>
                <span slot="footer" class="dialog-footer">
                  <el-button @click="add_title_cancel('form')">取 消</el-button>
                  <el-button v-if="updateTopicBtn" type="primary" @click="add_title_update('form')">更 新</el-button>
                  <el-button v-if="saveTopicBtn" type="primary" @click="add_title_save('form')">保 存</el-button>
                </span>
              </el-dialog>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-table :data="tableData" :fit="true" align="center" style="width: 100%" v-loading="TableLoading">
              <el-table-column type="index" label="编号" align="center" width="80"></el-table-column>
              <el-table-column prop="grade" label="年级" align="center" width="100">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.grade }}&nbsp;级</span>
                </template>
              </el-table-column>
              <el-table-column prop="title" label="课题类型" align="center" width="150"></el-table-column>
              <el-table-column prop="teaName" label="出题教师" align="center" width="100"></el-table-column>
              <el-table-column prop="description" align="center" label="课题描述"></el-table-column>
              <el-table-column width="" align="center" label="操作">
                <template slot-scope="scope">
                  <el-button v-if="scope.row.status=='0'" @click="topicPublish(scope.row)" type="text" size="medium">
                    发布
                  </el-button>
                  <el-button v-if="scope.row.status=='0'" @click="topicEdit(scope.row)" type="text" size="medium">编辑</el-button>
                  <el-button @click="topicDel(scope.row)" type="text" size="medium">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-tab-pane>
        <el-tab-pane label="学生管理" name="2">
          <el-col :span="24">
            <el-col :span="2">
              <el-button type="primary" icon="el-icon-search" @click="active2filtrate">筛选</el-button>
            </el-col>
            <el-col :span="5">
              <el-select v-model="activeGrade" placeholder="请选择" style="width: 100%">
                <el-option
                  v-for="item in gradeOptions"
                  :key="item"
                  :label="item+' 级'"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="3" :offset="14">
              <el-badge :value="StuCount" v-if="StuCount!=0" class="item">
                <el-button type="primary" plain icon="" @click="checkStudent">待审核学生</el-button>
              </el-badge>
              <!--              <el-button type="primary" plain icon="el-icon-plus" style="margin-left: 20px;float: right"-->
              <!--                         @click="dialogVisible2 = true">添加学生-->
              <!--              </el-button>-->
              <el-dialog
                title="添加学生"
                :visible.sync="dialogVisible2"
                width="30%"
                :before-close="handleClose2">
                <el-form :model="addStuForm">
                  <el-form-item label="姓名：" label-width="100px">
                    <el-popover
                      placement="top-start"
                      :disabled="flag"
                      trigger="hover"
                      :open-delay="500"
                      :close-delay="100"
                      @show="showContent"
                      :content="popover_content">
                      <el-cascader
                        ref="myinput"
                        placeholder="试试搜索"
                        :options="options"
                        @change="option_change1"
                        filterable style="width: 100%" slot="reference">
                      </el-cascader>
                    </el-popover>
                  </el-form-item>
                  <el-form-item label="选题方向：" label-width="100px">
                    <el-select v-model="title_type" placeholder="请选择" style="width: 100%;">
                      <el-option
                        v-for="item in addStuOption"
                        :key="item.title"
                        :label="item.title"
                        :value="item.title">
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible2 = false">取 消</el-button>
                    <el-button type="primary" @click="dialogVisible2 = false">确 定</el-button>
                  </span>
              </el-dialog>
            </el-col>
          </el-col>
          <el-col :span="24">
            <el-table
              v-loading="tableData2Load"
              :data="tableData2.filter(data => data.studentSelection.state=='1'&&data.studentSelection.grade==this.activeGrade)"
              :fit="true"
              show-summary
              :summary-method="getSummaries"
              align="center"
              style="width: 100%">
              <el-table-column prop="student.student.studentId" label="学号" align="center" width="160"></el-table-column>
              <el-table-column prop="student.student.name" label="姓名" align="center" width="100"></el-table-column>
              <el-table-column prop="clazz.clazzName" label="班级" align="center" width="140">
                <template slot-scope="scope">
                  <span>{{scope.row.student.majorName.substr(0,2)+scope.row.student.className}}班</span>
                </template>
              </el-table-column>
              <el-table-column label="指导老师" align="center">
                <template slot-scope="scope">
                  <span>{{TeaName}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="studentSelection.titleType" label="毕设方向" align="center"></el-table-column>
              <el-table-column prop="studentSelection.title" label="毕设题目" align="center"></el-table-column>
              <el-table-column prop="studentSelection.score" label="成绩" align="center" width="60">
                <template slot-scope="scope">
                  <span>{{scope.row.studentSelection.score==null?"--":scope.row.studentSelection.score}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="" align="center" label="操作">
                <template slot-scope="scope">
                  <el-button @click="handleClick2(scope.row)" type="text" size="medium">查看</el-button>
                  <el-button @click="handleDel2(scope.row)" type="text" size="medium">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-tab-pane>
        <el-tab-pane label="管理任务" name="3">
          <el-col :span="2">
            <el-button type="primary" icon="el-icon-search" @click="table4Click">搜索</el-button>
          </el-col>
          <el-col :span="5">
            <el-input
              placeholder="请输入关键字"
              v-model="input3"
              clearable>
            </el-input>
          </el-col>
          <el-col :span="2" :offset="14" style="margin-bottom: 13px">
            <el-button type="primary" plain icon="el-icon-plus" @click="addTask">添加任务</el-button>
          </el-col>
          <el-table :data="tableData4.filter(
          data => {
            return !search
            || data.type.toLowerCase().includes(search.toLowerCase())
            || data.topic.title.toLowerCase().includes(search.toLowerCase())
            || data.content.toLowerCase().includes(search.toLowerCase())
            || data.ask.toLowerCase().includes(search.toLowerCase())
          }
          )" border style="width: 100%" v-loading="TableLoading4">
            <el-table-column type="index" align="center" label="编号" width="80px" sortable></el-table-column>
            <el-table-column prop="type" align="center" label="任务类型" width="120px" sortable></el-table-column>
            <el-table-column prop="topic" align="center" label="毕设方向" width="" sortable>
              <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.topic.title }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="content" align="center" label="提交内容" width="" sortable>
              <!--              <template slot-scope="scope">-->
              <!--                <span v-for="o in scope.row.content">-->
              <!--                  <span>{{o}}，</span>-->
              <!--                </span>-->
              <!--              </template>-->
            </el-table-column>
            <el-table-column prop="ask" align="center" label="任务要求" width="" sortable></el-table-column>

            <el-table-column prop="stopDate" align="center" label="结束时间" width="" sortable></el-table-column>
            <el-table-column align="center" label="操作" width="220">
              <template slot-scope="scope">
                <el-button size="mini" @click="handlePublish(scope.row)" v-if="scope.row.state=='0'">发布</el-button>
                <el-button size="mini" @click="handleLook(scope.$index,'1')" v-if="scope.row.state=='1'">查看</el-button>
                <el-button size="mini" @click="handleLook(scope.$index,'2')" v-if="scope.row.state=='0'">编辑</el-button>
                <el-button size="mini" @click="handleDel(scope.row)">删除</el-button>
              </template>
            </el-table-column>

          </el-table>
        </el-tab-pane>
        <el-tab-pane label="任务审核" name="4">
          <el-table :data="tableData3" border style="width: 100%" v-loading="tableData3Loading">
            <el-table-column prop="stuInfo.student.studentId" align="center" label="学号" width=""
                             sortable></el-table-column>
            <el-table-column prop="stuInfo.student.name" align="center" label="姓名" width="" sortable></el-table-column>
            <el-table-column prop="stuInfo.colName" align="center" label="学院" width="" sortable

            ></el-table-column>
            <el-table-column prop="classes" align="center" label="班级" width="" sortable
                             :filters="[{text: 'Z移动1704班', value: 'Z移动1704班'}, {text: 'Z移动1701班', value: 'Z移动1701班'}]"
                             :filter-method="filterHandler">
              <template slot-scope="scope">
                <span>{{scope.row.stuInfo.majorName.substr(0,2)+scope.row.stuInfo.className+"班"}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="topicTitle.title" align="center" label="毕设方向" width="" sortable></el-table-column>
            <el-table-column prop="teacherReleaseTask.content" align="center" label="任务类型" width=""
                             sortable></el-table-column>
            <el-table-column align="center" label="审核" width="">
              <template slot-scope="scope">
                <el-button size="mini" @click="CheckTaskBtn(scope.$index, scope.row)">点击审核</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </el-col>
  </el-row>

</template>

<script>
    export default {
        name: "addTopic",
        data() {
            var checkType = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('不能为空'));
                }
                return callback();
            };
            var checkTeacher = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('不能为空'));
                }
                return callback();
            };
            var checkComment = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('不能为空'));
                }
                return callback();
            };
            var checkGrade = (rule, value, callback) => {
                if (value.length <= 0) {
                    return callback(new Error('不能为空'));
                }
                return callback();
            };
            return {
                activeGrade: "",
                StuCount: 0,
                tableData2Load: false,
                tableData3Loading: false,
                table4LookBtn: "编辑",
                userData: {},
                TeaName: "",
                saveTopicBtn: true,
                updateTopicBtn: false,
                addTopicLoading: false,
                TableLoading: true,
                TableLoading4: true,
                title_type: '',
                flag: false,
                input: "",
                input2: "学生",
                input3: "",
                dialogVisible: false,
                dialogVisible2: false,
                activeName: '1',
                tableData: [],
                tableData2: [],
                options: [
                    {
                        value: '11',
                        label: '信息工程学院顶顶顶顶顶顶顶',
                        children: [
                            {
                                value: '111',
                                label: 'Z移动1704班',
                                children: [{
                                    value: '1111',
                                    label: '一致的'
                                }, {
                                    value: '1112',
                                    label: '反馈'
                                }, {
                                    value: '1113',
                                    label: '效率'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }, {
                                    value: '1114',
                                    label: '可控'
                                }
                                ]
                            }, {
                                value: '112',
                                label: '设计原则1111',
                                children: [{
                                    value: '1121',
                                    label: '王永川-201761021203039'
                                }, {
                                    value: '1122',
                                    label: '反馈'
                                }, {
                                    value: '1123',
                                    label: '效率'
                                }, {
                                    value: '1124',
                                    label: '可控'
                                }]
                            }
                        ]
                    }, {
                        value: '12',
                        label: '指南',
                        children: [{
                            value: '121',
                            label: '设计原则',
                            children: [{
                                value: '122',
                                label: '一致'
                            }, {
                                value: 'fankui',
                                label: '反馈'
                            }, {
                                value: 'xiaolv',
                                label: '效率'
                            }, {
                                value: 'kekong',
                                label: '可控'
                            }]
                        }]
                    },
                ],
                EditRowData: [],
                form: {
                    type: '',
                    teacher: '',
                    comment: '',
                    grade: '',
                },
                addStuForm: {
                    type: '',
                    teacher: '',
                    comment: '',
                    grade: '',
                },
                gradeOptions: ["2017"],
                rules: {
                    type: [
                        {validator: checkType, trigger: 'blur'}
                    ],
                    teacher: [
                        {validator: checkTeacher, trigger: 'blur'}
                    ],
                    comment: [
                        {validator: checkComment, trigger: 'blur'}
                    ],
                    grade: [
                        {validator: checkGrade, trigger: 'blur'}
                    ]
                },
                formLabelWidth: '80px',
                popover_content: 'asdfsdf',
                fileList: [],
                tableData3: [],
                tableData4: [],
                tableAllData4: [],
                table4Filters: [
                    {text: 'Z移动1704班', value: 'Z移动1704班'},
                    {text: 'Z移动1701班', value: 'Z移动1701班'}
                ],
                value1: [new Date(), new Date()],
                addStuOption: [],
                search: '',
            }
        },
        methods: {
            active2filtrate() {
                this.activeGrade
                console.log(this.activeGrade);

            },
            addTopicBtn() {
                //添加按钮
                //切换  更新和保存 按钮
                this.dialogVisible = true;
                this.saveTopicBtn = true;
                this.updateTopicBtn = false;
                this.form.type = ""//清空输入框
                this.form.comment = ""//清空输入框
                this.form.grade = ""//清空输入框
            },
            topicPublish(row) {
                //发布 课题方向 按钮
                console.log("发布", row);
                var self = this;

                this.$confirm('确定要发布该课题吗？, 是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var body = {
                        teaName: row.teaName,
                        title: row.title,
                        description: row.description,
                        id: row.id,
                        status: "1",
                        teaId: row.teaId,
                        grade: row.grade,
                        count: row.count,
                    };
                    self.updateTable("update", body, "发布", self);
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消发布'
                    });
                });


            },
            topicEdit(row) {
                //编辑 课题方向 按钮
                this.saveTopicBtn = false;
                this.updateTopicBtn = true;
                console.log("编辑", row);

                this.EditRowData = row;
                this.form.teacher = row.teaName;
                this.form.type = row.title;
                this.form.comment = row.description;
                this.form.grade = row.grade;

                this.dialogVisible = true;

            },
            topicDel(row) {
                //删除 课题方向 按钮
                console.log("删除", row);
                var self = this;

                self.$confirm('确定要删除该课题吗？, 是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var body = {
                        teaName: row.teaName,
                        title: row.title,
                        description: row.description,
                        id: row.id,
                        status: row.status,
                        teaId: row.teaId,
                    };
                    self.updateTable("delete", body, "删除", self);
                }).catch(() => {
                    self.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            topicSearch() {
                this.loadTableData(this.input);
            },
            add_title_update(formName) {
                //更新按钮
                console.log("更新课题")
                var self = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {//输入框都不为空
                        this.addTopicLoading = true;//开启加载动画
                        //添加数据请求
                        var body = {
                            teaName: this.form.teacher,
                            title: this.form.type,
                            description: this.form.comment,
                            id: this.EditRowData.id,
                            status: this.EditRowData.status,
                            teaId: this.EditRowData.teaId,
                            grade: this.form.grade,
                        };
                        self.updateTable("update", body, "更新", self);
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            handleClick2(row) {
                //this.$router.push({path: '/teacher/index/StudentProgress', query: {}});
                console.log(row);
                this.$router.push({
                    path: '/teacher/index/StudentProgress',
                    query: {
                        id: row.studentSelection.topicId,
                        stuId: row.student.student.id
                    }
                })
            },
            handleDel2(row) {
                console.log("删除");
                console.log(row);
                console.log(row.studentSelection);
                var self = this;
                self.$confirm('确定要删除该学生吗？, 是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    self.$http.post(self.URL.api + "studentSelection/delete", self.qs.stringify(row.studentSelection))
                        .then(function (response) {
                            console.log(response.data);
                            if (response.data.flag) {
                                self.MyMessage("删除成功！！！", "success");
                                self.selTableData2();
                            } else {
                                self.MyMessage("删除失败，请稍后再试！", "warning");
                            }
                        })
                        .catch(function (error) {
                            self.MyMessage("删除失败，请稍后再试！", "warning");
                        });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            handleClose(done) {
                this.dialogVisible = false;
                this.$refs['form'].resetFields();
            },
            handleClose2(done) {
                done();
            },
            showContent() {
                //学生管理   添加学生
                //console.dir(this.$refs.myinput.$refs.input.$refs.input);
                var inp = this.$refs.myinput.$refs.input.$refs.input;
                //console.log(inp.clientWidth)
                //console.log(inp.scrollWidth)
                // console.log(inp.value)
                // console.log(inp.placeholder)
                if (inp.value !== '' && inp.clientWidth != inp.scrollWidth) {
                    this.popover_content = inp.value
                    this.flag = false;
                } else {
                    this.flag = true;
                }
            },
            option_change1(e) {
                console.log(e)
                this.flag = false;
            },
            //发布任务
            handlePublish(row) {
                //发布 课题方向 按钮
                console.log("发布", row);

                this.$confirm('确定要发布该任务吗？, 是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var self = this;
                    var body = {
                        id: row.id,
                    }
                    self.$http.post(self.URL.api + "teacherAddTask/publish", self.qs.stringify(body))
                        .then(function (response) {
                            console.log(response.data);
                            if (response.data.flag) {
                                self.MyMessage("发布成功！！！", "success");
                                self.selAllTble4Data();
                            } else {
                                self.MyMessage("发布失败，请稍后再试！", "warning");
                            }
                        })
                        .catch(function (error) {
                            self.MyMessage("发布失败，请稍后再试！", "warning");
                        });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消发布'
                    });
                });
            },
            handleDel(row) {
                this.$confirm('确定要删除该任务吗？, 是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var self = this;
                    self.TableLoading4 = true;
                    var body = {
                        id: row.id,
                    }
                    self.$http.post(self.URL.api + "teacherAddTask/delete", self.qs.stringify(body))
                        .then(function (response) {
                            console.log(response.data);
                            if (response.data.flag) {
                                self.MyMessage("删除成功！！！", "success");
                                self.selAllTble4Data();
                            } else {
                                self.MyMessage("删除失败，请稍后再试！", "warning");
                            }
                        })
                        .catch(function (error) {
                            self.MyMessage("删除失败，请稍后再试！", "warning");
                        });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            handleLook(index, f) {
                console.log(this.tableAllData4[index])
                this.$router.push({
                    path: '/teacher/index/TeaUpdateTask',
                    query: {
                        data2: encodeURIComponent(JSON.stringify(this.tableAllData4[index])),
                        flag: encodeURIComponent(JSON.stringify(f))
                    }
                });
                console.log(index);
            },
            filterHandler(value, row, column) {
                const property = column['property'];
                return row[property] === value;
            },
            data_change(e) {
                console.log(e)
            },
            addTask(e) {
                this.$router.push({path: '/teacher/index/PublishTask', query: {}});
            },
            CheckTaskBtn(index, row) {
                console.log(row);
                this.$router.push({
                    path: '/student/index/CheckStuTask',
                    query: {
                        active: "4",
                        id: encodeURIComponent(JSON.stringify(row)),
                    }
                })
            },
            getSummaries(param) {
                const {columns, data} = param;
                const sums = [];
                //console.dir(columns.length)
                sums[columns.length - 1] = data.length + " / " + "15";
                sums[0] = '已选人数/总人数';
                return sums;
            },
            checkStudent() {
                this.$router.push({path: '/teacher/index/CheckStudent', query: {}});
            },
            add_title_cancel(formName) {//取消保存课题
                console.log("取消")
                this.$refs[formName].resetFields();
                this.dialogVisible = false;
            },
            add_title_save(formName) {//保存课题
                console.log("保存课题")
                var self = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {//输入框都不为空
                        this.addTopicLoading = true;//开启加载动画
                        //添加数据请求
                        var body = {
                            teaName: this.form.teacher,
                            title: this.form.type,
                            description: this.form.comment,
                            teaId: this.userData.id,
                            grade: this.form.grade
                        }
                        //console.log(this.userData.id)
                        self.updateTable("add", body, "添加", self);
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            loadTableData(content) {//加载表数据
                var self = this;
                self.TableLoading = true;
                console.log(self.userData.id)
                self.$http.post(self.URL.api + 'teacherTopic/select', self.qs.stringify({
                    str: content,
                    teaId: self.userData.id
                }))
                    .then(function (response) {
                        self.tableData = response.data.data;
                        self.TableLoading = false;
                        console.log("加载11111", self.tableData)
                    })
                    .catch(function (error) {
                        self.TableLoading = false;
                        console.log("加载222")
                    });
            },
            updateTable(url, body, msg, self) {
                console.log("body", body);
                self.$http.post(self.URL.api + 'teacherTopic/' + url, self.qs.stringify(body))
                    .then(function (response) {//添加成功 返回值
                        self.addTopicLoading = false;//关闭加载动画
                        if (response.data.flag) {
                            self.$message({
                                message: msg + '成功！！！',
                                type: 'success'
                            });
                            self.dialogVisible = false;
                            self.loadTableData("");
                            self.form.type = ""//清空输入框
                            self.form.comment = ""//清空输入框
                        } else {
                            self.$message({
                                message: msg + '失败，请稍后重试！！！',
                                type: 'warning'
                            });
                            self.dialogVisible = false;
                        }
                    })
                    .catch(function (error) {
                        self.addTopicLoading = false;
                        self.$message({
                            message: msg + '失败，请稍后重试！！！',
                            type: 'warning'
                        });
                    });
            },
            selAllTble4Data() {
                var self = this;
                self.TableLoading4 = true;
                self.$http.post(self.URL.api + 'teacherAddTask/select', self.qs.stringify({teaId: this.UserInfo.getUserInfo().id}))
                    .then(function (response) {
                        if (response.data.data != null) {
                            self.tableAllData4 = response.data.data;
                            console.log(response.data.data)
                            self.tableData4 = [];
                            response.data.data.forEach(re => {
                                self.tableData4.push(re.task)
                            });
                            console.log("tableData4", response.data.data)
                            console.log("tableData44444444", self.tableData4)
                        }
                        self.TableLoading4 = false;
                    })
                    .catch(function (error) {
                        self.TableLoading4 = false;
                        console.log("加载11111", error)
                    });
            },
            MyMessage(msg, type) {
                this.$message({
                    message: msg,
                    type: type
                });
            },
            selTableData2() {
                var self = this;
                self.tableData2Load = true;
                self.$http.post(self.URL.api + 'studentSelection/teaSel', self.qs.stringify({teaId: self.userData.id}))
                    .then(function (response) {
                        console.log(response.data)
                        if (response.data.flag) {
                            console.log(response.data.data)
                            self.tableData2 = response.data.data;
                            self.StuCount = 0;
                            self.tableData2.forEach(re => {
                                //console.log(re);
                                if (re.studentSelection.state == "0") {
                                    self.StuCount += 1;
                                }
                            });
                            self.tableData2Load = false;
                        }
                        self.tableData2Load = false;
                    })
                    .catch(function (error) {
                        self.tableData2Load = false;
                        console.log("加载11111", error)
                    });
            },
            selTableData3() {
                var self = this;
                self.tableData3Loading = true;
                self.$http.post(self.URL.api + 'studentsDoTasks/selStuTaskByTeaId', self.qs.stringify({id: self.userData.id}))
                    .then(function (response) {
                        console.log(response.data.data)
                        if (response.data.flag) {
                            console.log(response.data.data)
                            self.tableData3 = response.data.data;
                            self.tableData3Loading = false;
                        } else {
                            self.tableData3Loading = false;
                        }
                    })
                    .catch(function (error) {
                        self.tableData3Loading = false;
                        console.log("selTableData3", error)
                    });
            },
            selGrade() {
                // /studentSelection")selGrade
                var self = this;
                // self.$http.post(self.URL.api + 'studentSelection/selGrade')
                //     .then(function (response) {
                //         console.log(response.data)
                //         if (response.data.flag) {
                //             self.gradeOptions = response.data.data;
                //         } else {
                //
                //         }
                //     })
                //     .catch(function (error) {
                //         console.log(error)
                //     });
                self.gradeOptions=[];
                var myDate = new Date();
                var year = myDate.getFullYear();
                for (var i = year; i >= 2016; i--) {
                    self.gradeOptions.push(i);
                }
            },
            addStuOptionM() {
                var self = this;
                self.$http.post(self.URL.api + 'teacherTopic/select', self.qs.stringify({
                    str: null,
                    status: "1",
                    teaId: self.UserInfo.getUserInfo().id
                }))
                    .then(function (response) {
                        self.addStuOption = response.data.data;
                        console.log("addStuOption", response.data.data)
                    })
                    .catch(function (error) {
                        console.log("addStuOption", error)
                    });
            },
            table4Click() {
                console.log(this.input3)
                this.search=this.input3;
            },

        },
        mounted: function () { //mounted　表示这个 Vue 对象加载成功了
            this.userData = this.UserInfo.getUserInfo();
            console.log(this.userData);
            this.TeaName = this.userData.teaname;
            this.form.teacher = this.userData.teaname;
            this.activeGrade = this.gradeOptions[this.gradeOptions.length - 1];

            this.selGrade();
            this.loadTableData("");
            this.selAllTble4Data();
            this.selTableData2();
            this.addStuOptionM();
            this.selTableData3();


            //任务管理
            //this.activeName = this.$route.params.act == null ? "1" : this.$route.params.act;//跳到第三个
            console.log(this.$route.params.act)
            if (this.$route.params.act != undefined) {
                this.activeName = this.$route.params.act;
            }
        }
    }
</script>

<style scoped>
  .tag_style {
    margin: 1px;
  }

  .row >>> .el-tabs__content {
    overflow: visible;
  }

  .row >>> .el-badge__content.is-fixed {
    position: absolute;
    top: 0;
    right: 14px;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    padding: 0;
    line-height: 24px;
  }
</style>
